
#include <iostream>
#include <vector>
using namespace std;
//循环链表解决
typedef struct Node
{
	struct Node *next;
	int val;
	Node(int val,struct Node *next){
		this->val = val;
		this->next = next;
	}
}Node;
int M;
void show(Node *head){  
	Node *cur = head->next;
	while(cur->next!=head->next){
		cout<<cur->val<<" ";
		cur = cur->next;
	}
	cout<<cur->val<<endl;
}
Node *rear = NULL;
void init(Node * &head){
	head = new Node(0,NULL);
	Node *cur = new Node(1,NULL);
	head->next = cur;
	for(int i=2;i<=10;i++){
		Node *temp = new Node(i,head->next);
		cur->next = temp;
		cur = temp;
	}
	rear = cur;
}

int main()
{
  freopen("data.txt","r",stdin);
  cin>>M;
  vector<int> X(M,0);
  for(int i=0;i<M;i++) cin>>X[i];
  Node *head;
 init(head);
 show(head);
 
  for(int i=0;i<M;i++){
  	Node *fast = head->next,*slow = head;
  	if (fast->val==X[i])
  		continue;//是第一个节点，无需更改 
	  
  	
  	while(fast->val!=X[i]){
  		fast = fast->next;
  		slow = slow->next;
	}
	if (fast->next==head->next){
		//最后一个节点特殊处理
		head->next = fast;
		rear = slow;
	}
	else{//常规节点 
		slow->next = fast->next;
	fast->next = head->next;
	head->next = fast;
	rear->next = fast;
	}

	show(head);
  }
  
  
  return 0;
}